package com.gears_software.sxdc.dccx.ui.view;

import android.Manifest;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;

import com.gears_software.sxdc.dccx.R;
import com.gears_software.sxdc.dccx.application.DCCXApplication;
import com.gears_software.sxdc.dccx.ui.activity.ReleaseScheduleActivity_;

import org.androidannotations.annotations.App;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;


/**
 * Created by SunMuran on 2017/8/1.
 * 显示车主点击已完成界面的view，里面显示的是一个个的乘客
 */
@EViewGroup(R.layout.item_chengke)
public class ChengKeInformationListItemView extends LinearLayout {
    Context context;
    @App
    DCCXApplication app;
    @ViewById
    TextView tv_nicheng;
    @ViewById
    ImageView img_avatar;
    @ViewById
    TextView tv_phone_number;
    @ViewById
    TextView tv_call_phone;
    @ViewById
    RatingBar rb_chezhu_ratingBar;
    @ViewById
    TextView tv_pingjia;
    @ViewById
    TextView tv_tousu;

    // 声明对话框
    AlertDialog dialog;


    public ChengKeInformationListItemView(Context context) {
        super(context);
        this.context = context;
    }

    public void bind() {
        tv_call_phone.setTypeface(app.iconfont);
    }

    //点击评价摁钮
    @Click
    void tv_pingjia() {
        float rating = rb_chezhu_ratingBar.getRating();
        int a = (int) rating;
        Toast.makeText(context, "评价了" + a + "颗星", Toast.LENGTH_SHORT).show();
    }

    public void a() {
        rb_chezhu_ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                rb_chezhu_ratingBar.setRating(rating);
            }
        });
    }

    //点击打电话摁钮拨打电话
    @Click
    void tv_call_phone() {
        Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:10010"));
        try {
            context.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    //点击了投诉按钮
    @Click
    void tv_tousu() {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        // 配置对话框的属性
        builder.setTitle("警告");
        builder.setMessage("您确定要投诉他吗？？？");
        builder.setIcon(R.mipmap.tishi);
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { //设置确定按钮
            @Override
            public void onClick(DialogInterface dialog, int which) {
//                Intent intent = new Intent(context, CheZhuComplainActivity_.class);
//                context.startActivity(intent);

            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { //设置取消按钮
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        //参数都设置完成了，创建并显示出来
        builder.create().show();


//        new MaterialDialog.Builder(context)
//                .title("提示")
//                .titleGravity(GravityEnum.CENTER)
//
//                .titleColorRes(R.color.colorActionbar)
//                .content("您确定要投诉他吗？？？")
//                .contentColorRes(R.color.colorFontGray)
//                .positiveText("确定")
//                .positiveColor(ContextCompat.getColor(context, R.color.colorFontBlue))
//                .onPositive(new MaterialDialog.SingleButtonCallback() {
//                    @Override
//                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
//                        Intent intent = new Intent(context, ReleaseScheduleActivity_.class);
//                        context.startActivity(intent);
//                    }
//                })
//                .negativeText("取消")
//                .negativeColor(ContextCompat.getColor(context, R.color.colorFontGray))
//                .onNegative(new MaterialDialog.SingleButtonCallback() {
//                    @Override
//                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
//
//                    }
//                })
//                .buttonsGravity(GravityEnum.CENTER)
//                .show();
    }


}
